package com.cuit.controller;


import com.cuit.dao.impl.OrderDaoImpl;
import com.cuit.pojo.Order;
import com.cuit.pojo.Patient;
import com.cuit.service.Impl.OrderServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.List;

@WebServlet("/checkAllOrder")
public class CheckOrder extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        HttpSession se = req.getSession();
        Patient patient = (Patient) se.getAttribute("patient");
        String id=patient.getP_id();
        OrderServiceImpl service = new OrderServiceImpl();
        List<Order> orders = service.queryByID(id);
        se.setAttribute("orderInfo",orders);
        resp.sendRedirect("pages/order/showAllOrder.jsp");

    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }
}
